<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2203：Pku2448 A New Operating System</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Pku2448 A New Operating System</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Pku2448 A New Operating System</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                Pku2448 A New Operating System                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：259MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div style="text-indent: 24pt"><span style="font-size: medium">最近阳阳接下了一个任务：编写一个操作系统。</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">编写操作系统可是一个大工程，阳阳花费了很多时间在上面，他本想很快完成的，但是IOI在即，再怎么样也不能耽误了世界赛啊！但是雇主的要求有很严格，要求阳阳一定要在IOI之前完成这个系统的编写，所以他不得不找到你请求帮助，人多力量大嘛，你就帮帮他咯。</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">你的任务很简单，只要编写一个内存管理系统就可以了。你的程序需要支持以下9个操作：</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">CreateProcess(PID,Memory,Priority)：新建一个过程，编号为PID，其占用的内存为Memory，优先级（称为外部优先级）为Priority；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">AddMessage(PID,Priority)：在过程PID中新建一个任务，其优先级（称为内部优先级）为Priority；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">Run：在当前所有任务中间找出一个优先级最高的运行并输出&rsquo;Run: Priority&rsquo;，这里的优先级定义为其内部优先级与外部优先级的积，如果两个任务的优先级一样则优先运行PID较小的任务，如果没有任何任务则输出&rsquo;Empty&rsquo;；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">ChangePriority(PID,NewValue)：将过程PID的外部优先级改变为NewValue；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">GetMemory(PID,Memory)：将过程PID的内存占用增加Memory；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">FreeMemory(PID,Memory)：将过程PID的内存占用减少Memory；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">RunProcess(PID)：将过程PID中找出一个内部优先级最高的运行并输出&rsquo;Run Process: Priority&rsquo;，如果该过程中如果没有任何任务则输出&rsquo;Empty&rsquo;；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">CloseMaxMemory：将当前所有过程中内存占用最高的过程关闭，占用内存一样则选择PID较小的关闭，如果当前没有任何过程则输出&rsquo;Empty&rsquo;；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">CloseProcess(PID)：将过程PID关闭。</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">PS：</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">1)&nbsp;&nbsp; 任务运行后自动被删除；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">2)&nbsp;&nbsp; 对于CreateProcess，如果PID已经存在则输出&rsquo;Error&rsquo;，对于其他操作，如果PID不存在则输出&rsquo;Error&rsquo;，这种情况下该操作将被忽略；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">3)&nbsp;&nbsp; 当一个过程的内存占用小于等于0时则该过程将被自动关闭；</span></div>
<div style="text-indent: 24pt"><span style="font-size: medium">&nbsp;</span></div></p><hr/><h3>输入格式</h3><p><div style="text-indent: 21.75pt"><span style="font-size: medium">第一行一个正整数N，表示操作总数，开始内存中过程为空；</span></div>
<div style="text-indent: 21.75pt"><span style="font-size: medium">然后N行每行按照如上格式描述一个任务；</span></div>
<div><span style="font-size: medium">&nbsp;</span></div></p><hr/><h3>输出格式</h3><p><div>&nbsp;</div>
<div style="text-indent: 21.25pt"><span style="font-size: medium">按照如上描述输出。</span></div></p><hr/><h3>样例输入</h3><pre>11
CloseMaxMemory
CreateProcess(1,100,1)
CreateProcess(2,200,1)
CreateProcess(3,300,1)
AddMessage(1,9)
AddMessage(2,19)
AddMessage(1,10)
GetMemory(2,999)
CloseMaxMemory
Run
RunProcess(1)

</pre><hr/><h3>样例输出</h3><pre>Empty
Run: 10
Run Process: 9

</pre><hr/><h3>提示</h3><p><p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">0 &lt; N &lt;= 100,000<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">对于</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">65%</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">的数据范围</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">N &lt;= 1,000</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">；</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">对于</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">90%</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">的数据范围将只出现</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">CreateProcess</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">、</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">AddMessage</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">、</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">Run</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">、</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">RunProcess</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">操作；</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">对于</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">90%</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">的数据</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">PID</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">的范围为</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="Times New Roman">[1 .. N]</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">；</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></p>
<p></p></p><hr/><h3>题目来源</h3><p>模拟题系列</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2203" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2203" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>